<!-- 消息和通知 -->

<script setup>
import { ref, onMounted, watch, toRefs } from 'vue';
import { ElBadge, ElEmpty } from 'element-plus';
import { storeToRefs } from 'pinia';
import mitt from '../../common/common-helper';
import { useCommonStore } from '../../stores';
import AddNotification from './AddNotification.vue';
// import MessageDetailsModel from './MessageDetailsModel.vue';
import MessageModel from './MessageModel.vue';
import NotificationDetailsModel from './NotificationDetailsModel.vue';

const props = defineProps({
  messageShow: {
    type: Boolean,
  },
});
const { messageShow } = toRefs(props);

const commonStore = useCommonStore();

const { unReaderMessageNum } = storeToRefs(commonStore);

const selectState = ref('消息');
const showMsgDialog = ref(false);
const detailTShowDialog = ref(false);
const detailXShowDialog = ref(false);
const addShowDialog = ref(false);
const current = ref(1);
const detailLookInfo = ref({}); //消息/通知详情内容

const noticeTable = ref([
  {
    id: 193,
    createdDate: '2023-11-27 17:42:59',
    createdBy: '53577011515535360',
    creatorName: '杨哲勿删',
    title: '测试',
    content:
      '测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试',
    subjectId: null,
    msgType: 2,
    picture: [
      {
        filename: '野猪1.jpeg',
        object: '53577011515535360/202311/92561cf96db74a1aa29a6ea08dc23534.jpeg',
        length: 74760,
      },
      {
        filename: '野猪2.png',
        object: '53577011515535360/202311/e0867a0ecb874acda769cf0aad52900e.png',
        length: 253882,
      },
      {
        filename: '野猪3.jpg',
        object: '53577011515535360/202311/f2bb7b92f529448b892868ced77cbfda.jpg',
        length: 49219,
      },
      {
        filename: '野猪4.jpg',
        object: '53577011515535360/202311/a68f628264044aa5bbb299dcb5840eeb.jpg',
        length: 80887,
      },
      {
        filename: '野猪6.jpg',
        object: '53577011515535360/202311/20e34bb886ae48e680cf3c550d227d74.jpg',
        length: 101975,
      },
      {
        filename: '野猪7.jpg',
        object: '53577011515535360/202311/62ba5460fee743e2a139537b3cb3fa0b.jpg',
        length: 36259,
      },
      {
        filename: '野猪1.jpeg',
        object: '53577011515535360/202311/c8e31c989e3e41f7ae1cd028286c82d8.jpeg',
        length: 74760,
      },
      {
        filename: '野猪2.png',
        object: '53577011515535360/202311/502d40a7bfff40abbdedca8f9cd2cbc1.png',
        length: 253882,
      },
      {
        filename: '野猪3.jpg',
        object: '53577011515535360/202311/4722e3cc877c40eea5efd08a9b1b62d6.jpg',
        length: 49219,
      },
    ],
    annex: [
      {
        filename: 'gis测试注意事项.docx',
        object: '53577011515535360/202311/cbe6c170320f484cb0603d21ffd52a04.docx',
        length: 4800,
      },
      {
        filename: 'gis测试注意事项.docx',
        object: '53577011515535360/202311/56555b62507d4df9a8e187701bf7699d.docx',
        length: 4800,
      },
      {
        filename: 'gis测试注意事项.docx',
        object: '53577011515535360/202311/7029acdbadfd4988b8e3ebad1415d6b8.docx',
        length: 4800,
      },
      {
        filename: 'gis测试注意事项.docx',
        object: '53577011515535360/202311/924a3aad499a45c1ac9a2e14b8674578.docx',
        length: 4800,
      },
      {
        filename: 'gis测试注意事项.docx',
        object: '53577011515535360/202311/0064900471c54604a862462a85a97a2e.docx',
        length: 4800,
      },
    ],
    readTime: null,
    status: null,
  },

  {
    id: 33,
    createdDate: '2023-09-05 15:28:55',
    createdBy: '53577011515535360',
    creatorName: '杨哲勿删',
    title: '测试正常通知',
    content: '测试正常进行通知',
    subjectId: null,
    msgType: 2,
    picture: [
      {
        filename: '3.jpg',
        object: '53577011515535360/202309/65a3caabad1e46e2af07f174c96f524b.jpg',
        length: 97664,
      },
      {
        filename: 'd62a6059252dd42a035df1b760c1a4b3c8eab853.jpeg',
        object: '53577011515535360/202309/f8ad245301194eda941863631246c7c9.jpeg',
        length: 210786,
      },
      {
        filename: '2 - 副本.bmp',
        object: '53577011515535360/202309/a7df452492c241bdb0fdf47fe222cc1b.bmp',
        length: 35784,
      },
      {
        filename: '测试2.png',
        object: '53577011515535360/202309/910d53c74f9148edaccfbf8cec0fb213.png',
        length: 129242,
      },
      {
        filename: 'cd198badfaabcb122dc7bf287a51fcd.jpg',
        object: '53577011515535360/202309/34b84a39351e4e44b3ab595584b75aad.jpg',
        length: 446406,
      },
      {
        filename: 'ww.jpg',
        object: '53577011515535360/202309/62e3c250bda7472faaaaa422fe7c18bc.jpg',
        length: 619210,
      },
      {
        filename: 'qq.jpg',
        object: '53577011515535360/202309/102bae5daa094903b1cf9096d739f258.jpg',
        length: 52512,
      },
      {
        filename:
          'src=http---imagepphcloud.thepaper.cn-pph-image-137-492-266.jpg&refer=http---imagepphcloud.thepaper.jpg',
        object: '53577011515535360/202309/3a0e89192bf2445f9afcf99a5002e8d3.jpg',
        length: 227374,
      },
      {
        filename: 'd62a6059252dd42a035df1b760c1a4b3c8eab853.jpeg',
        object: '53577011515535360/202309/761beaa09171422ea4841042a6a25ef3.jpeg',
        length: 210786,
      },
    ],
    annex: [
      {
        filename: '林业工业管理站工作职责内容.docx',
        object: '53577011515535360/202309/2473c8fbdec949afa500506b4761e0d9.docx',
        length: 11468,
      },
      {
        filename: '林业厅地下停车场管理规定.docx',
        object: '53577011515535360/202309/2e4414f90402474fa38e51adef7f7691.docx',
        length: 12083,
      },
      {
        filename: '林业系统“七五”普法依法治理工作目标管理责任书.docx',
        object: '53577011515535360/202309/5d598a8e4a064cd3b30649b97ca52e94.docx',
        length: 13518,
      },
      {
        filename: '区林业局财务管理办法.docx',
        object: '53577011515535360/202309/021c8e42f0e44d51b4153f2dc64d5a62.docx',
        length: 14332,
      },
      {
        filename: '市林业局机关办公楼管理规定.docx',
        object: '53577011515535360/202309/40ff5580ca3d40a0af7ed2823d682c73.docx',
        length: 13377,
      },
    ],
    readTime: '2023-11-22 18:28:23',
    status: null,
  },
  {
    id: 24,
    createdDate: '2023-09-05 15:01:16',
    createdBy: '50746350803058688',
    creatorName: '菲菲',
    title:
      '测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试',
    content:
      '测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试',
    subjectId: null,
    msgType: 2,
    picture: [
      {
        filename: '20230715.jpg',
        object: '50746350803058688/202309/6b3d806cae104287a29923ebad929055.jpg',
        length: 260417,
      },
      {
        filename: '20230717.jpg',
        object: '50746350803058688/202309/9dd882459d284a42ae9a293212173e57.jpg',
        length: 260787,
      },
      {
        filename: '20230720.jpg',
        object: '50746350803058688/202309/41a2401b9b174ebb9309bb58574aeee4.jpg',
        length: 238001,
      },
      {
        filename: '20230721.jpg',
        object: '50746350803058688/202309/f7adec7303a147979b4feb1aa9026a60.jpg',
        length: 261493,
      },
      {
        filename: '20230722.jpg',
        object: '50746350803058688/202309/02476768d29f4e27887b7abf65e87050.jpg',
        length: 261553,
      },
      {
        filename: '20230724.jpg',
        object: '50746350803058688/202309/8f85881e017a43ecb79beac8cb0dfdb5.jpg',
        length: 238492,
      },
      {
        filename: '20230801.jpg',
        object: '50746350803058688/202309/3442c29421e84a10b66db79d2ca3e091.jpg',
        length: 236977,
      },
      {
        filename: '20230804.jpg',
        object: '50746350803058688/202309/683f0c6378eb4e869fef21af8ca626c2.jpg',
        length: 265037,
      },
      {
        filename: '20230807.jpg',
        object: '50746350803058688/202309/cbc9f330a91d4e69b195f670330d2152.jpg',
        length: 278377,
      },
    ],
    annex: [
      {
        filename:
          '测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档.docx',
        object: '50746350803058688/202309/cc40eb26b07549c38ea2c621cd3ce8c5.docx',
        length: 11124,
      },
      {
        filename: '工作簿1 - 副本 - 副本.xls',
        object: '50746350803058688/202309/0c17d22d54534bf5a02b2d443081ee31.xls',
        length: 8538,
      },
      {
        filename:
          '测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档测试文档.docx',
        object: '50746350803058688/202309/1a3015f698534823b2355966852406bf.docx',
        length: 11124,
      },
      {
        filename: '测试文件word - 副本.pdf',
        object: '50746350803058688/202309/2e1fa577382542598b7f35cd05f8d3d2.pdf',
        length: 49330,
      },
      {
        filename: '生态资源保护-保护动物.xlsx',
        object: '50746350803058688/202309/d0abf476de0f4a089d980b5f9360a7d9.xlsx',
        length: 6686,
      },
    ],
    readTime: '2023-11-22 18:28:23',
    status: null,
  },
  {
    id: 15,
    createdDate: '2023-08-29 15:02:00',
    createdBy: '50746408495710208',
    creatorName: '菲',
    title: '测试发通知给菲F',
    content: '测试',
    subjectId: null,
    msgType: 2,
    picture: [],
    annex: [],
    readTime: '2023-11-22 18:28:23',
    status: null,
  },

  {
    id: 132,
    createdDate: '2023-11-07 14:12:50',
    createdBy: '73958745557893120',
    creatorName: '杨A',
    title: '标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题',
    content:
      '内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容',
    subjectId: null,
    msgType: 2,
    picture: [
      {
        filename: '2 - 副本 - 副本.bmp',
        object: '73958745557893120/202311/86350d8b3df84184b6ad4b1bff2a7d2e.bmp',
        length: 35784,
      },
      {
        filename: '1657525360076.jpg',
        object: '73958745557893120/202311/ce327cf6dc2c4f4195462abeb7e6effd.jpg',
        length: 157414,
      },
      {
        filename: 'a2dd7433a5a69d21735863bf2b4cddfc_1.jpg',
        object: '73958745557893120/202311/eb83f8b9ea264d08b73d9b5561fc2aa2.jpg',
        length: 47289,
      },
      {
        filename: 'IMG_3782.jpg',
        object: '73958745557893120/202311/90b0cee2d39a475089760425447b6771.jpg',
        length: 363753,
      },
      {
        filename:
          'src=http---imagepphcloud.thepaper.cn-pph-image-137-492-266.jpg&refer=http---imagepphcloud.thepaper.jpg',
        object: '73958745557893120/202311/42aab0fd435542d9b5f66e89e0784743.jpg',
        length: 227374,
      },
      {
        filename: 'ww.jpg',
        object: '73958745557893120/202311/175885422b7a4cb49dead24b1245f45d.jpg',
        length: 619210,
      },
      {
        filename: '白虎.jpg',
        object: '73958745557893120/202311/64538208abc44b10ac40db347d05689a.jpg',
        length: 30376,
      },
      {
        filename: 'ddce0ddb80fc48e1c0ed6ecbf33ac3c.jpg',
        object: '73958745557893120/202311/5745f1bace374ec2a10486faa4afa8bb.jpg',
        length: 368229,
      },
      {
        filename: 'DSCF4726.jpg',
        object: '73958745557893120/202311/3426fc4e5a3b41baac219cead570a062.jpg',
        length: 393760,
      },
    ],
    annex: [
      {
        filename: '员工手册-制度规范2022.04.11(1).pdf',
        object: '73958745557893120/202311/b1a7d45fff33424893da31cff467721c.pdf',
        length: 3251191,
      },
      {
        filename: '法律法规.pdf',
        object: '73958745557893120/202311/48bf258d53634d49854a52b99e975118.pdf',
        length: 72788,
      },
      {
        filename: '林业工业管理站工作职责内容.docx',
        object: '73958745557893120/202311/c2a1871ad4434b0e9dd9a44765f0c686.docx',
        length: 11468,
      },
      {
        filename: '测试文件.xlsx',
        object: '73958745557893120/202311/976a913074b04001b0be892e26b5025f.xlsx',
        length: 283476,
      },
      {
        filename: '测试文件.xls',
        object: '73958745557893120/202311/7e570c1269e244b2aac1c291d9c3f009.xls',
        length: 40960,
      },
    ],
    readTime: '2023-11-22 18:28:22',
    status: null,
  },
  {
    id: 131,
    createdDate: '2023-11-07 13:51:22',
    createdBy: '79372865958502400',
    creatorName: '测试B',
    title: '这里是通知的标题',
    content: '这里是通知的内容',
    subjectId: null,
    msgType: 2,
    picture: [
      {
        filename: '2 - 副本 - 副本.bmp',
        object: '79372865958502400/202311/794ce87ed8c34766910d37f84ecaee02.bmp',
        length: 35784,
      },
      {
        filename: '2 - 副本.bmp',
        object: '79372865958502400/202311/9048ad78977e4f1f89779eaa86f6801e.bmp',
        length: 35784,
      },
      {
        filename: '3.jpg',
        object: '79372865958502400/202311/10f80bf4e802440f8aa1904b8880fd21.jpg',
        length: 97664,
      },
      {
        filename: '11.jpg',
        object: '79372865958502400/202311/f0b9e43d0af64179b60c79c1e8292840.jpg',
        length: 130618,
      },
      {
        filename: '22.jpg',
        object: '79372865958502400/202311/cddf295dad04427fa1ae3499654789b8.jpg',
        length: 142326,
      },
      {
        filename: '28b91f8e7e414ce9ba688949043dc8c2.jpg',
        object: '79372865958502400/202311/e54250022f514f04a1a69acefbd80389.jpg',
        length: 34355,
      },
      {
        filename: '33(1)(1).jpg',
        object: '79372865958502400/202311/8fc7bfcc1ec045df8e4aa00bc3a6f258.jpg',
        length: 4205656,
      },
      {
        filename: '33.jpg',
        object: '79372865958502400/202311/fa401513a2554131853f8762a6a7b8a1.jpg',
        length: 158274,
      },
      {
        filename: '32491ec36d8d329992c1378704fac5dc_1c6f6506c2380f2655c903.jpg',
        object: '79372865958502400/202311/974574eb148e409eba12de6dcdb6375a.jpg',
        length: 237568,
      },
    ],
    annex: [
      {
        filename: '5m.docx',
        object: '79372865958502400/202311/0774e5c18aa8450da52a3f42e1937c98.docx',
        length: 17026001,
      },
      {
        filename: '员工手册-制度规范2022.04.11(1).pdf',
        object: '79372865958502400/202311/5d32d565c36441d7bcc711ee19f2eacd.pdf',
        length: 3251191,
      },
      {
        filename: '法律法规.pdf',
        object: '79372865958502400/202311/eda4958bf2ba43edb432d9e8a3a88025.pdf',
        length: 72788,
      },
      {
        filename: '测试文件.xlsx',
        object: '79372865958502400/202311/0957c638133a4e24b566a21175c19e4b.xlsx',
        length: 283476,
      },
      {
        filename: '林业工业管理站工作职责内容.docx',
        object: '79372865958502400/202311/e616216d85244d5d8e423bd7aaee1f19.docx',
        length: 11468,
      },
    ],
    readTime: '2023-11-22 18:28:22',
    status: null,
  },
  {
    id: 50,
    createdDate: '2023-09-08 14:16:12',
    createdBy: '52952154230702080',
    creatorName: '菲F',
    title: 'ces',
    content: 'ces',
    subjectId: null,
    msgType: 2,
    picture: [],
    annex: [],
    readTime: '2023-09-08 17:41:45',
    status: null,
  },
  {
    id: 27,
    createdDate: '2023-09-05 15:07:14',
    createdBy: '53577011515535360',
    creatorName: '杨哲勿删',
    title: ' 测试',
    content:
      '窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光意识地上霜\n窗前明月光',
    subjectId: null,
    msgType: 2,
    picture: [],
    annex: [],
    readTime: '2023-09-05 15:13:41',
    status: null,
  },
]);
const messageTable = ref([
  {
    id: 53,
    createdDate: '2023-09-08 14:43:13',
    title: '绿甲壳虫类型的病虫害',
    content: '1',
    subjectId: null,
    readTime: null,
    status: null,
  },
  {
    id: 51,
    createdDate: '2023-09-08 14:24:21',
    title: '绿甲壳虫类型的病虫害',
    content: '11',
    subjectId: null,
    readTime: null,
    status: null,
  },
  {
    id: 48,
    createdDate: '2023-09-08 14:12:58',
    title: '绿甲壳虫类型的病虫害',
    content: '1',
    subjectId: null,
    readTime: null,
    status: null,
  },
  {
    id: 47,
    createdDate: '2023-09-08 14:08:20',
    title: '绿甲壳虫类型的病虫害',
    content: '32323',
    subjectId: null,
    readTime: null,
    status: null,
  },
  {
    id: 46,
    createdDate: '2023-09-08 14:08:16',
    title: '滥砍乱发',
    content: '1111',
    subjectId: null,
    readTime: null,
    status: null,
  },
  {
    id: 45,
    createdDate: '2023-09-08 14:07:47',
    title: '绿甲壳虫类型的病虫害',
    content: '1',
    subjectId: null,
    readTime: null,
    status: null,
  },
  {
    id: 44,
    createdDate: '2023-09-08 14:01:44',
    title: '绿甲壳虫类型的病虫害',
    content: '1',
    subjectId: null,
    readTime: null,
    status: null,
  },
  {
    id: 42,
    createdDate: '2023-09-08 13:49:27',
    title: '绿甲壳虫类型的病虫害',
    content: '测试消息',
    subjectId: null,
    readTime: null,
    status: null,
  },
  {
    id: 41,
    createdDate: '2023-09-08 13:45:49',
    title: '绿甲壳虫类型的病虫害',
    content: 'ces',
    subjectId: null,
    readTime: null,
    status: null,
  },

  {
    id: 52,
    createdDate: '2023-09-08 14:42:51',
    title: '绿甲壳虫类型的病虫害',
    content:
      '测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试',
    subjectId: null,
    readTime: '2023-09-08 16:32:02',
    status: null,
  },
  {
    id: 54,
    createdDate: '2023-09-08 15:16:45',
    title: '破坏林地',
    content: '测试',
    subjectId: null,
    readTime: '2023-09-08 16:31:58',
    status: null,
  },
]);

const btnImage = ref({
  xi_icon: new URL('../../assets/images/icon/消息.png', import.meta.url).href,
  xia_icon: new URL('../../assets/images/icon/消息active.png', import.meta.url).href,

  tz_icon: new URL('../../assets/images/icon/通知.png', import.meta.url).href,
  tza_icon: new URL('../../assets/images/icon/通知active.png', import.meta.url).href,

  info_icon: new URL('../../assets/images/icon/信息.png', import.meta.url).href,
  xinF_icon: new URL('../../assets/images/icon/信封.png', import.meta.url).href,
});

watch(
  unReaderMessageNum,
  () => {
    //!  获取消息Api
  },
  { deep: true },
);

const changeSelect = (type) => {
  selectState.value = type;

  if (type == '消息') {
    //!  获取消息Api
  } else {
    //! 通知列表Api
  }
};

const closeMsgDialog = (val) => {
  showMsgDialog.value = val;

  if (!val) {
    //! 通知列表Api
    //! 获取消息Api
  }
};

const handleLookAll = () => {
  showMsgDialog.value = true;
};

// 全部已读
const handleReadAll = () => {
  if (selectState.value == '消息') {
    //! 已读全部消息Api
  } else {
    //! 已读全部通知Api
  }
};

const closeDetailDialog = () => {
  detailXShowDialog.value = false;
  detailTShowDialog.value = false;

  if (current.value == 2) {
    showMsgDialog.value = true;
  }
};

const detailXShowDialogEmit = () => {
  detailXShowDialog.value = true;
};

const detailTShowDialogEmit = () => {
  detailTShowDialog.value = true;
};

// 获取详情信息
const detailInfoEmit = (val) => {
  current.value = 2;
  detailLookInfo.value = val;
};

const handleAddDialog = (val) => {
  addShowDialog.value = val;

  if (val) {
    showMsgDialog.value = false;
  } else {
    showMsgDialog.value = true;
  }
};

// 查看通知
const handleNotification = (val) => {
  current.value = 1;
  detailLookInfo.value = val;
  detailTShowDialog.value = true;
  //! 标记通知为已读Api
};

// 查看消息
const handleMessage = (val) => {
  current.value = 1;
  detailLookInfo.value = val;
  detailXShowDialog.value = true;

  // ! 标记消息为已读Api
};

onMounted(() => {
  //! 通知列表Api
  //! 消息列表Api
});

const handleMouse = () => {
  mitt.emit('handleMouseleave', false);
};
</script>
<template>
  <div v-if="messageShow" class="message_root" @mouseleave="handleMouse()">
    <div class="top_select">
      <div :class="selectState == '消息' ? 'select_item is_select' : 'select_item'" @click="() => changeSelect('消息')">
        <img :src="selectState == '消息' ? btnImage.xia_icon : btnImage.xi_icon" />消息({{
          unReaderMessageNum.unreadMessage
        }})
      </div>
      <div :class="selectState == '通知' ? 'select_item is_select' : 'select_item'" @click="() => changeSelect('通知')">
        <img :src="selectState == '通知' ? btnImage.tza_icon : btnImage.tz_icon" />通知({{
          unReaderMessageNum.unreadNotification
        }})
      </div>
    </div>

    <div v-if="selectState == '消息'" class="mes_main">
      <ElEmpty v-if="!messageTable?.length" description="暂无消息" class="empty_" />
      <div v-else>
        <div v-for="item in messageTable" :key="item.id" class="main_list" @click="handleMessage(item)">
          <div class="list_avatar">
            <ElBadge v-if="item.readTime == null" is-dot>
              <img :src="btnImage.info_icon" />
            </ElBadge>
            <img v-if="item.readTime !== null" :src="btnImage.info_icon" />
          </div>
          <div class="list_info">
            <div class="list_item">
              <p :title="item.title">{{ item.title }}事件上报</p>
              <p>{{ item.createdDate }}</p>
            </div>
            <div class="info" :title="item.content">{{ item.content }}</div>
          </div>
        </div>
      </div>
    </div>

    <div v-if="selectState == '通知'" class="mes_main">
      <ElEmpty v-if="!noticeTable?.length" description="暂无通知" class="empty_" />

      <div v-else>
        <div v-for="item in noticeTable" :key="item.id" class="main_list" @click="handleNotification(item)">
          <div class="list_avatar_tz">
            <ElBadge v-if="item.readTime == null" is-dot>
              <img :src="btnImage.xinF_icon" />
            </ElBadge>
            <img v-if="item.readTime !== null" :src="btnImage.xinF_icon" />
          </div>
          <div class="list_info">
            <div class="list_item">
              <p :title="item.title">{{ item.title }}</p>
              <p>{{ item.createdDate }}</p>
            </div>
            <div class="info" :title="item.content">{{ item.content }}</div>
          </div>
        </div>
      </div>
    </div>

    <div class="all_btn">
      <p @click="handleReadAll()">全部已读</p>
      <p @click="handleLookAll()">查看全部 &gt;</p>
    </div>
  </div>

  <!-- 查看全部 -->
  <MessageModel
    :show-msg-dialog="showMsgDialog"
    :select-state="selectState"
    @close-msg-dialog="closeMsgDialog"
    @detail-x-show-dialog-emit="detailXShowDialogEmit"
    @detail-t-show-dialog-emit="detailTShowDialogEmit"
    @detail-info-emit="detailInfoEmit"
    @handle-add-dialog="handleAddDialog"
  />

  <!-- 查看详情(事件管理上报)-->
  <!-- <MessageDetailsModel
    :detail-x-show-dialog="detailXShowDialog"
    :detail-look-info="detailLookInfo"
    :select-state="selectState"
    @close-detail-dialog="closeDetailDialog"
  /> -->
  <!-- 查看详情(通知)-->
  <NotificationDetailsModel
    :detail-t-show-dialog="detailTShowDialog"
    :detail-look-info="detailLookInfo"
    :select-state="selectState"
    @close-detail-dialog="closeDetailDialog"
  />
  <!-- 添加通知-->
  <AddNotification :add-show-dialog="addShowDialog" @handle-add-dialog="handleAddDialog" />
</template>

<style scoped lang="scss">
.message_root {
  position: absolute;
  top: 70px;
  right: 8px;
  z-index: 9;
  box-sizing: border-box;
  width: 420px;
  height: 320px;
  padding: 20px 20px;
  color: #666666;
  background-color: #ffffff;
  border-radius: 20px;
  -webkit-box-shadow: -1px 4px 38px -17px rgba(0, 0, 0, 0.3);
  box-shadow: -1px 4px 38px -17px rgba(0, 0, 0, 0.3);

  .top_select {
    display: flex;
    justify-content: space-evenly;
    padding-bottom: 10px;
    font-size: 16px;
    .select_item {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 120px;
      height: 32px;
      color: #666666;
      background: #efefef;
      border-radius: 4px;
      cursor: pointer;
      img {
        width: 16px;
        height: 15px;
        margin-right: 5px;
      }
    }
    .is_select {
      color: #387dfb;
      background: #eaf0fb;
    }
  }

  .mes_main {
    width: 100%;
    height: 193px;
    overflow: auto;
    cursor: pointer;
    .main_list {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      height: 98px;
      padding: 21px 0 22px 0;
      border-bottom: 1px solid #e5e6eb;
      .list_avatar,
      .list_avatar_tz {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 46px;
        height: 46px;
        border-radius: 50%;

        img {
          width: 30px !important;
          height: 30px !important;
        }
        :deep(.el-badge__content.is-dot) {
          width: 12px;
          height: 12px;
        }
      }

      .list_avatar {
        background: #2e6dd9;
      }

      .list_avatar_tz {
        background: #45b6eb;

        img {
          width: 20px !important;
          height: 20px !important;
        }
      }
      .list_info {
        font-size: 16px;
        .list_item {
          display: flex;
          align-items: center;
          justify-content: space-between;
          margin-bottom: 16px;
          p:first-child {
            width: 140px;
            overflow: hidden;
            color: #333333;
            font-size: 18px;
            white-space: nowrap;
            text-overflow: ellipsis;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
          }
          p:nth-child(2) {
            color: #999999;
          }
        }

        .info {
          width: 300px;
          overflow: hidden;
          color: #999999;
          white-space: nowrap;
          text-overflow: ellipsis;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
        }

        div {
          white-space: nowrap;
        }
      }
    }
  }

  .mes_main::-webkit-scrollbar {
    display: none;
    width: 0 !important;
  }
  .all_btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 58px;
    font-size: 18px;
    border-top: 1px solid #e5e6eb;
    cursor: pointer;

    p:first-child {
      color: #387dfb;

      &:hover {
        color: #89a9e0;
      }
    }

    p:nth-child(2) {
      color: #666666;

      &:hover {
        color: #838383;
      }
    }
  }

  .empty_ {
    width: 100%;
    height: 160px;
  }
}
</style>
